use std

pkg dispatch =
	const register : (cmd: byte[:], f: (params: byte[:][:] -> void) -> void)
	const call : (cmd: byte[:], params: byte[:][:] -> bool)
;;

var tbl : std.htab(byte[:], (params: byte[:][:] -> void))#

const __init__ = {
	tbl = std.mkht()
}

const register = {cmd, f
	std.htput(tbl, cmd, f)
}

const call = {cmd, params
	std.put("disp {} -  {}\n",cmd,params)
	match std.htget(tbl, cmd)
	| `std.Some f:
		f(params)
		-> true
	| `std.None: -> false
	;;
}
